#ifndef __C_CROSSFIRE_SCENEMANAGER_H_
#define __C_CROSSFIRE_SCENEMANAGER_H_

#include "ISceneManager.h"
//#include "IDrawRenderer.h"
//#include "ISceneNode.h"

#include "CCameraNode.h"
#include "CSkyBoxNode.h"

namespace cfe
{
	class CSceneManager : public ICF_SceneManager//, public ICF_SceneNode
	{
	public:
		CSceneManager(ICF_DrawRenderer* render) : m_render(render)
		{
			m_pParent = NULL;
			m_currcamera = NULL;
			m_pMng = this;
		}
		ICF_DrawRenderer* getDrawRenderer() const {return m_render;}

		ICF_CameraNode* addVectorsCamera()
		{
			ICF_CameraNode* cam = new CVectorsCamera();
			addChildren(cam);
			return cam;
		}

		ICF_SkyBoxNode* addSkyBox(const LPWSTR filenames[] = 0, float size = 0)
		{
			ICF_SkyBoxNode* skybox = new CSkyBoxNode();
			addChildren(skybox);

			if((filenames)&&(size>0))
				skybox->Init(filenames, size);
			return skybox;
		}

		void setCurrentCamera(ICF_CameraNode* cam)
		{
			m_currcamera = cam;
		}

		ICF_CameraNode* getCurrentCamera()
		{
			return m_currcamera;
		}

		void cameraToRender(ICF_CameraNode* cam)
		{
			m_render->GetDevice()->SetTransform( D3DTS_VIEW, cam->CalcViewMatrix());
			m_render->GetDevice()->SetTransform( D3DTS_PROJECTION, cam->CalcProjectionMatrix());
		}

		void render() {};

		void RenderScene() 
		{
			cameraToRender(m_currcamera);
			renderAll();
		};

		void Destroy()
		{
			RemoveAll();
			delete this;
		}
		//void renderAll() {};
	private:
		ICF_DrawRenderer* m_render;
		ICF_CameraNode* m_currcamera;
	};
};

#endif